﻿using Md.Api.Model;
using Md.Api.Model.Manage.MdArticleFieldExpansion.Request;
using Md.Api.Service.Manage.MdArticleFieldExpansion;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 文章字段扩展
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/md/articleFieldExpansion")]
public class MdArticleFieldExpansionController : ControllerBase
{
    /// <summary>
    /// 通过编号删除文章字段扩展服务
    /// </summary>
    public DeleteMdArticleFieldExpansionByIdService deleteMdArticleFieldExpansionByIdService { get; set; }
    /// <summary>
    /// 通过编号删除文章字段扩展
    /// </summary>
    /// <param name="ids">编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{ids}")]
    public async Task<ResponseMessageModel> DeleteMdArticleFieldExpansionById(string ids, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteMdArticleFieldExpansionByIdModel();

        model.Ids = ids;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteMdArticleFieldExpansionByIdService.Execute(model));
    }

    /// <summary>
    /// 添加文章字段扩展服务
    /// </summary>
    public InsertMdArticleFieldExpansionService insertMdArticleFieldExpansionService { get; set; }
    /// <summary>
    /// 添加文章字段扩展
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdArticleFieldExpansion([FromBody] RequestInsertMdArticleFieldExpansionModel model)
    {
        return await Task.Run(() => insertMdArticleFieldExpansionService.Execute(model));
    }

    /// <summary>
    /// 通过编号更新文章字段扩展服务
    /// </summary>
    public UpdateMdArticleFieldExpansionByIdService updateMdArticleFieldExpansionByIdService { get; set; }
    /// <summary>
    /// 通过编号更新文章字段扩展
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateMdArticleFieldExpansionById([FromBody] RequestUpdateMdArticleFieldExpansionByIdModel model)
    {
        return await Task.Run(() => updateMdArticleFieldExpansionByIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取文章字段扩展服务
    /// </summary>
    public GetMdArticleFieldExpansionByIdService getMdArticleFieldExpansionByIdService { get; set; }
    /// <summary>
    /// 通过编号获取文章字段扩展
    /// </summary>
    /// <param name="id">编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{id}")]
    public async Task<ResponseMessageModel> GetMdArticleFieldExpansionById(long id, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdArticleFieldExpansionByIdModel();

        model.ArticleExpanId = id;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdArticleFieldExpansionByIdService.Execute(model));
    }

    /// <summary>
    /// 获取文章字段扩展列表服务
    /// </summary>
    public GetMdArticleFieldExpansionListService getMdArticleFieldExpansionListService { get; set; }
    /// <summary>
    /// 获取文章字段扩展列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetMdArticleFieldExpansionList([FromBody] RequestGetMdArticleFieldExpansionListModel model)
    {
        return await Task.Run(() => getMdArticleFieldExpansionListService.Execute(model));
    }

    /// <summary>
    /// 分页获取文章字段扩展列表服务
    /// </summary>
    public GetMdArticleFieldExpansionPageListService getMdArticleFieldExpansionPageListService { get; set; }
    /// <summary>
    /// 分页获取文章字段扩展列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdArticleFieldExpansionPageList([FromBody] RequestGetMdArticleFieldExpansionPageListModel model)
    {
        return await Task.Run(() => getMdArticleFieldExpansionPageListService.Execute(model));
    }
}

